# _*_ coding : utf-8 _*_
# @Time: 2024/11/06 10:38
# @Author : 石文帅	
# @File : testcase08_2防火检查站
# @Project : python_slfh
from server.slfhWorkbench import *
from selenium.webdriver.chrome.service import Service
from xpathDictionary.slfhXpath import *


class test(unittest.TestCase):

    @classmethod
    def setUpClass(cls):
        cls.wd = webdriver.Chrome(service=Service(driver_path))
        cls.wd.get(url_path)
        cls.wd.maximize_window()
        login(cls.wd)

    @classmethod
    def tearDownClass(cls):
        log.info('搜索自动化测试的内容，并且删除')
        fireCheckpoint_search(cls.wd, name='自动化导入检查站')
        fireCheckpoint_del(cls.wd, resource_name='自动化导入检查站')
        cls.wd.quit()
        log.info('----------------------------------------------------------')

    def testcase08_2防火检查站(self):
        """
        防火检查站 导入测试
        :return:
        """
        log.info('testcase08_2防火检查站')
        search_menu(self.wd, '物防设施')
        log.info('开始进入-防火检查站')
        locate_click(self.wd, device['防火检查站-table'])
        assert_select_menu(self.wd, '物防设施', '防火检查站')

        log.info('导入失败无必填表头测试')
        upload_file_by_input(self.wd, device['防火检查站-导入input'], f'{path_file}防火检查站-失败导入无表头.zip')
        time.sleep(1)
        text = element_exist_gettext(self.wd, resources['分类资源-导入报错提示'], 5)
        assert_equal(text, '模板错误！,缺少【类型（必填）】列')

        log.info('导入失败无分类资源类型测试')
        upload_file_by_input(self.wd, device['防火检查站-导入input'], f'{path_file}防火检查站-失败导入无分类资源类型.zip')
        time.sleep(1)
        text = element_exist_gettext(self.wd, resources['分类资源-导入报错下载提示'], 5)
        assert_equal(text, '导入数据失败，是否下载详细错误信息文件?')
        locate_click(self.wd, resources['分类资源-导入报错下载取消'])
        time.sleep(2)

        log.info('导入成功测试')
        upload_file_by_input(self.wd, device['防火检查站-导入input'], f'{path_file}防火检查站-成功导入.zip')
        time.sleep(1)
        assert_true(element_exist(self.wd, resources['资源列表成功提示'], 10))



